<?php

class CouponModel extends BaseModel
{
    var $table  = 'coupon';
    var $prikey = 'coupon_id';
    
    /*
     * @auth bzyy
     * 2015-6-5 10:32:15
     * 自动验证
     */
    var $_autov = array(
    		'coupon_name' => array(
    				'required'  => true,    //必填
    				'min'       => 1,       //最短1个字符
    				'max'       => 100,     //最长100个字符
    				'filter'    => 'trim',
    		),
    		'coupon_value'  => array(
    				'required'  => true,
    				'filter'    => 'intval',
    		),
    		'min_amount'  => array(
    				'required'  => true,
    				'filter'    => 'intval',
    				'min'       => 1,
    		),

    );
    
    var $_relation = array(
    		'belongs_to_user' => array(
    				'model'         => 'member',
    				'type'          => BELONGS_TO,
    				'foreign_key'   => 'user_id',
    				'reverse'       => 'has_couponsn',
    		),
    		'has_couponsn' => array(
    				'model'         => 'couponsn',
    				'type'          => HAS_MANY,
    				'foreign_key'   => 'coupon_id',
    				'reverse'       => 'has_couponsn',
    		),
    );
    
    /*
     * 检测和过滤内容
     * 检测时间等内容是否合适
     * @auth bzyy
     * 2015-6-5 10:41:42
     */
    public function bzyycheck($data)
    {
    	
    }
}

?>
